package heap

import "errors"

type FnLess func(a interface{}, b interface{}) bool

type tComparator struct {
	fnLess FnLess
}

func NewComparator(fn FnLess) IComparator {
	if fn == nil {
		panic(gNullArgumentError)
	}

	return &tComparator{
		fnLess: fn,
	}
}


func (me *tComparator) Less(a interface{}, b interface{}) bool {
	if a == nil || b == nil {
		panic(gNullArgumentError)
	}
	return me.fnLess(a, b)
}


var gNullArgumentError = errors.New("null argument error")